<%@ page import="com.car.entyti.User" %>
<%@ page import="com.car.service.UserService" %><%--
  Created by IntelliJ IDEA.
  User: 韩壮
  Date: 2021/5/26
  Time: 14:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改用户信息</title>

    <link type="text/css" href="<%= request.getContextPath()%>/css/updateUser.css" rel="stylesheet">
</head>
<body>
<%
    Cookie[] cookies = request.getCookies();
    String token = null;

    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals("TOKEN")) {
                token = cookie.getValue();
            }
        }
    }
    User user = new User();
    if (token == null) {

    }
    else {
        UserService userService = new UserService();
        user = userService.getUserByToken(token);
        out.print("欢迎使用carpool拼车， <span style = 'color: red' >" + user.getName() + "</span>");
    }
%>
<div class="content">
    <form action="<%= request.getContextPath() %>/updateUser" method="post">
        <input type="hidden" name="id" value="<%=user.getId()%>">
        <div><strong>姓名</strong><input type="text" name="name" value="<%=user.getName()%>"></div>
        <div><strong>性别</strong><input type="text" name="sex" value="<%=user.getSex()%>">
        </div>
        <div><strong>电话</strong><input type="text" name="phone" value="<%=user.getPhone()%>"></div>
        <div><strong>类型</strong><input type="text" name="type" value="<%=user.getType()%>" disabled="disabled">

        </div>
        <div><strong>账户</strong><input type="text" name="account" value="<%=user.getAccount()%>"></div>
        <div><strong>密码</strong><input type="password" name="password" value="<%=user.getPassword()%>">
        </div>
        <div>
            <button class="user-button" type="submit">确定修改</button>
            <button class="user-button" type="button" onclick="location.href = 'User.jsp'">取消修改</button>
        </div>
    </form>
    <div class="bottom">
        <a href="wenti.jsp">出现问题？联系客服</a>
    </div>
</div>
</body>
<script>

</script>
</html>
